package com.sf.osms.dep.processor.util;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ResourceUtils {
	
	private static Logger logger = LoggerFactory.getLogger(ResourceUtils.class);
	protected static final ResourceBundle BUNDLE = ResourceBundle.getBundle("properties/application");// 读取properties文件配置
	
	public static String getApplicationConfig(String key){
		if(StringUtils.isEmpty(key)){
			return null;
		}
		String value = null;
		try {
			value = BUNDLE.getString(key);
		} catch (MissingResourceException e) {
			logger.error("*****get application.properties property occur exception******");
			logger.error(ExceptionUtils.getExceptionStackString(e));
			value = null;
		}
		
		if(StringUtils.isBlank(value)){
			return null;
		}
		
		return value.trim();
	}
	
	public static void main(String[] args) {
		System.out.println(getApplicationConfig("dep.scan.agent"));
	}
}
